package com.family.web.controller.pedigree;


import com.family.common.core.controller.BaseController;
import com.family.common.core.domain.AjaxResult;
import com.family.common.core.page.TableDataInfo;
import com.family.pedigree.domain.FamilyUserInfo;
import com.family.pedigree.service.IFamilyUserInfoService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 * 个人信息表 前端控制器
 * </p>
 *
 * @author forever
 * @since 2025-01-16
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/family/user/info")
public class FamilyUserInfoController extends BaseController {

    private final IFamilyUserInfoService familyUserInfoService;

    @PostMapping
    public AjaxResult add(@RequestBody FamilyUserInfo familyUserInfo) {
        familyUserInfoService.add(familyUserInfo);
        return AjaxResult.success();
    }

    @PutMapping
    public AjaxResult edit(@RequestBody FamilyUserInfo familyUserInfo) {
        familyUserInfoService.updateById(familyUserInfo);
        return AjaxResult.success();
    }

    @GetMapping("/page")
    public TableDataInfo page(FamilyUserInfo familyUserInfo) {
        startPage();
        return getDataTable(familyUserInfoService.selectPage(familyUserInfo));
    }

    @DeleteMapping("/{infoId}")
    public AjaxResult delById(@PathVariable Long infoId) {
        familyUserInfoService.delById(infoId);
        return AjaxResult.success();
    }
}
